function w = mPerceptron(c1, c2, tMax)

mu = 1;

s1 = size(c1);
s2 = size(c2);

y1(1:s1(1)) = 1;
Yc1 = horzcat(y1', c1);

y2(1:s2(1)) = 1;
Yc2 = horzcat(y2', c2);
Yc2 = Yc2*-1;

sYc1 = size(Yc1);
sYc2 = size(Yc2);

a(1:sYc1(2)) = 0.25;
a = a';

t=0;
success=1;
stop = 0;

h = waitbar(0,'Calcul du percptron...');
set(h,'Name','Perceptron');
while(stop==0)
    success = 1;
    
    for i=1:sYc1(1)
        v = Yc1(i,:);
        tmp = a'*v';
        if(tmp < 0)
            a = a+mu*v';
            success = 0;
        end
    end
    
    for i=1:sYc2(1)
        v = Yc2(i,:);
        tmp = a'*v';
        if(tmp < 0)
            a = a+mu*v';
            success = 0;
        end
    end
    
    t = t+1;
    mu = 1/log(t+1);
    
    if(t>tMax | success==1 | mu<0.00001)
        stop = 1;
    end
    waitbar(t/tMax);
end
close(h);
 

if(success==1)
    w=a;
    min1 = min(min(c1), min(c2));
    max1 = max(max(c1), max(c2));
    axis([min1(1), max1(1), min1(2), max1(2), min1(3), max1(3)]);
    v = axis;
    hold on
    %traceSurface(a, v(1), v(2), v(3), v(4));
    plane3(a(2:end), 30);
    pline(a(2:end),30);
    plot3(c1(:,1), c1(:,2), c1(:,3), 'b.');
    plot3(c2(:,1), c2(:,2), c2(:,3), 'r.');
else
    w=-1;
    fprintf('Separation lineaire non trouvee\n');
end

end